using CodeSaude.Domain.Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace CodeSaude.Infrastructure.Data.EntityConfig
{
    public class cep_bairroMap : EntityTypeConfiguration<cep_bairro>
    {
        public cep_bairroMap()
        {
            // Primary Key
            this.HasKey(t => t.id_bairro);

            // Properties
            this.Property(t => t.id_bairro)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.uf)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.bairro)
                .IsRequired()
                .HasMaxLength(144);

            this.Property(t => t.bairro_abrev)
                .HasMaxLength(72);

            // Table & Column Mappings
            this.ToTable("cep_bairro");
            this.Property(t => t.id_bairro).HasColumnName("id_bairro");
            this.Property(t => t.uf).HasColumnName("uf");
            this.Property(t => t.id_municipio).HasColumnName("id_municipio");
            this.Property(t => t.bairro).HasColumnName("bairro");
            this.Property(t => t.bairro_abrev).HasColumnName("bairro_abrev");

            // Relationships
            this.HasRequired(t => t.cep_municipio)
                .WithMany(t => t.cep_bairro)
                .HasForeignKey(d => d.id_municipio);

        }
    }
}
